<template>
  <div>
    <el-container>
      <el-header>
        <el-row :gutter="20">
          <el-col
            :span="12"
            :offset="0"
            style="font-size: 16pt; color: white; text-align: left"
          >
            <el-radio-group v-model="isCollapse">
              <el-radio-button :label="false">展开</el-radio-button>
              <el-radio-button :label="true"
                >收起</el-radio-button
              > </el-radio-group
            >&nbsp;
            <span>Rbac角色权限管理</span>
          </el-col>
          <el-col :span="12" :offset="0" style="text-align: right">
            <span v-if="userName" style="color: #fff; padding: 10px">
              欢迎您：{{ userName }}
            </span>
            <el-button
              type="danger"
              size="default"
              icon="el-icon-error"
              @click="logout"
              >退出系统</el-button
            >
          </el-col>
        </el-row>
      </el-header>
      <el-container>
        <el-aside width="230px">
          <el-menu
            :default-active="$route.path"
            class="el-menu-vertical-demo"
            background-color="#545c64"
            text-color="#fff"
            active-text-color="#ffd04b"
            :router="true"
            @open="handleOpen"
            @close="handleClose"
            :collapse="isCollapse"
          >
            <el-submenu index="1">
              <template slot="title">
                <i class="el-icon-s-custom"></i>
                <span>用户管理</span>
              </template>
              <el-menu-item index="/AdminList">
                <i class="el-icon-setting"></i>
                <span slot="title">用户列表</span>
              </el-menu-item>
              <el-menu-item index="/AddAdmin">
                <i class="el-icon-setting"></i>
                <span slot="title">新增新用户</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="2">
              <template slot="title">
                <i class="el-icon-sell"></i>
                <span>角色管理</span>
              </template>
              <el-menu-item index="/RoleList">
                <i class="el-icon-setting"></i>
                <span slot="title">角色管理</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="3">
              <template slot="title">
                <i class="el-icon-sell"></i>
                <span>菜单管理</span>
              </template>
              <el-menu-item index="/MenuList">
                <i class="el-icon-setting"></i>
                <span slot="title">菜单列表</span>
              </el-menu-item>
            </el-submenu>
            <el-submenu index="4">
              <template slot="title">
                <i class="el-icon-sell"></i>
                <span>数据统计</span>
              </template>
              <el-menu-item index="/goodsSalesCount">
                <i class="el-icon-setting"></i>
                <span slot="title">商品销售统计</span>
              </el-menu-item>
              <el-menu-item index="/goodsSalesCountByDate">
                <i class="el-icon-setting"></i>
                <span slot="title">日期范围内销售统计</span>
              </el-menu-item>
              <el-menu-item index="/RegUserCount">
                <i class="el-icon-setting"></i>
                <span slot="title">注册用户统计</span>
              </el-menu-item>
              <el-menu-item index="/LoginCount">
                <i class="el-icon-setting"></i>
                <span slot="title">登录次数统计</span>
              </el-menu-item>
              <el-menu-item index="/GoodsTypeCount">
                <i class="el-icon-setting"></i>
                <span slot="title">商品分类统计</span>
              </el-menu-item>
              <el-menu-item index="/GoodsSaleCount">
                <i class="el-icon-setting"></i>
                <span slot="title">商品销售统计</span>
              </el-menu-item>
              <el-menu-item index="/StatSaleByDate">
                <i class="el-icon-setting"></i>
                <span slot="title">商品销售日期统计</span>
              </el-menu-item>
              <el-menu-item index="/OrderGoodsCount">
                <i class="el-icon-setting"></i>
                <span slot="title">订单数量统计</span>
              </el-menu-item>
              <el-menu-item index="/OrderCount">
                <i class="el-icon-setting"></i>
                <span slot="title">订单数量（日周月年）统计</span>
              </el-menu-item>
              <el-menu-item index="/HotGoods">
                <i class="el-icon-setting"></i>
                <span slot="title">热销商品排行</span>
              </el-menu-item>
              <el-menu-item index="/RandView">
                <i class="el-icon-setting"></i>
                <span slot="title">吃什么饭</span>
              </el-menu-item>
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view />
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  data() {
    return {
      userName: window.localStorage.getItem("userName"),
      isCollapse: false,
    };
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath);
    },
    logout() {
      this.$confirm("系统将要退出，确定继续吗？", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "error",
      })
        .then(() => {
          this.$router.push("/");
        })
        .catch(() => {});
    },
  },
};
</script>
<style>
.el-header,
.el-footer {
  background-color: #1c4de3;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #545c64;
  color: #333;
  text-align: left;
  line-height: 200px;
  height: 88vh;
}

.el-main {
  /* background-color: #e9eef3; */
  color: #333;
  text-align: left;
  padding: 20px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>